package wxy;

import java.util.Arrays;

public class Week1_2_2_isStraight {
    public boolean isStraight(int[] nums) {
        Arrays.sort(nums);
        int zeroCnt = 0;
        for (int i = 0; i < 4; i++) {
            if (nums[i] == 0) {
                zeroCnt++;
            } else {
                int diff = nums[i + 1] - nums[i];
                if (diff == 0) {
                    return false;
                }
                if (diff > 1) {
                    zeroCnt = zeroCnt - (diff - 1);
                    if (zeroCnt < 0) {
                        return false;
                    }
                }
            }
        }
        return true;
    }
}
